package qf.sail.controller;

import qf.sail.contents.CodeMsg;
import qf.sail.entity.Order;
import qf.sail.service.OrderService;
import qf.sail.service.impl.OrderServiceImpl;
import qf.sail.vo.ResultVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/getOrderInfo")
public class GetOrderInfoServlet extends BaseServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OrderService orderService = new OrderServiceImpl();
        long orderId = Long.parseLong(req.getParameter("orderId"));
        Order order = orderService.getOrderById(orderId);
        if(order == null){
            repError(resp, CodeMsg.GET_ORDER_ERR);
            return;
        }

        ResultVO resultVO = new ResultVO();
        resultVO.addData("order",order);
        repSuccess(resp,resultVO);
    }
}
